package game.players.user.running;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Sprite;
import com.uqbar.vainilla.events.constants.Key;

import game.players.SoccerPlayer;

public class WithoutBallLeftRunningUser extends WithoutBallAbstractRunningUser {

	public WithoutBallLeftRunningUser(SoccerPlayer player, double x, double y) {
		super(player, x, y);
		this.getPlayer().setAppearance(new Animation(0.1,
				Sprite.fromImage("/images/goal3_corriendo2.png").crop(0, 4, 35, 63).scale(1.5).flipHorizontally(),
				Sprite.fromImage("/images/goal3_corriendo2.png").crop(70, 6, 42, 57).scale(1.5).flipHorizontally(),
				Sprite.fromImage("/images/goal3_corriendo2.png").crop(143, 0, 34, 64).scale(1.5).flipHorizontally(),
				Sprite.fromImage("/images/goal3_corriendo2.png").crop(212, 3, 41, 58).scale(1.5).flipHorizontally()
				));
	}
	
	@Override
	public void update(DeltaState deltaState) {
		if(deltaState.isKeyBeingHold(Key.LEFT) && deltaState.isKeyBeingHold(Key.UP))
			this.getPlayer().setState(new WithoutBallDiagonalLeftUpRunningUser(this.getPlayer(), -this.getPlayer().getMovementSpeed(), -this.getPlayer().getMovementSpeed()));
		else {
			if(deltaState.isKeyBeingHold(Key.LEFT) && deltaState.isKeyBeingHold(Key.DOWN))
				this.getPlayer().setState(new WithoutBallDiagonalLeftDownRunningUser(this.getPlayer(), -this.getPlayer().getMovementSpeed(), this.getPlayer().getMovementSpeed()));
		}
		
		if (!deltaState.isKeyBeingHold(Key.LEFT))
			this.getPlayer().setState(new WithoutBallStationaryRunningUser(this.getPlayer()));
		
		super.update(deltaState);
	}

	@Override
	public boolean isRight() {
		return false;
	}

}
